#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=2e5+100;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL f[maxn];
bool check(LL x,string t1,LL lent1,string t2,LL lent2){
    LL j=1;
    for(LL i=1;j<=lent2&&i<=lent1;i++){
        if(f[i]>x&&t1[i]==t2[j]) j++;
    }
    if(j>lent2) return true;
    else return false;
}
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  string s1="#";string a;cin>>a;
  s1+=a;
  string s2="#";string b;cin>>b;
  s2+=b;
  LL len1=s1.size()-1;LL len2=s2.size()-1;
  for(LL i=1;i<=len1;i++){
    LL x;cin>>x;
    f[x]=i;
  }
  LL l=0;LL r=len1;
  while(l<r){
    LL mid=(l+r+1)>>1;
    if(check(mid,s1,len1,s2,len2)) l=mid;
    else r=mid-1;
  }
  cout<<l<<"\n";
return 0;
}
